package com.cardone.platform.authority.service;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

import com.cardone.common.cache.Caches;
import com.cardone.common.dto.PaginationDto;
import com.cardone.platform.authority.dto.NavigationDto;
import com.cardone.platform.configuration.service.SiteUrlService;

/**
 * 导航服务
 *
 * @author yaohaitao
 */
public interface NavigationService {
	/**
	 * spring bean id
	 */
	String BEAN_ID = "com.cardone.platform.authority.service.NavigationService";

	/**
	 * 保存:导航
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param saveNavigation
	 *          导航对象
	 *
	 * @return 导航对象
	 */
	@Deprecated
	@Transactional
	@CacheEvict(value = NavigationService.BEAN_ID, allEntries = true)
	<P> P saveByIdOrCode(final Class<P> mappedClass, final NavigationDto saveNavigation);

	/**
	 * 查询:导航
	 *
	 * @param siteCode
	 *          站代码
	 * @param typeCode
	 *          类别代码
	 * @param parentId
	 *          父级标识
	 * @param level
	 *          层级
	 * @return 导航对象集合
	 */
	@Cacheable(value = NavigationService.BEAN_ID, key = Caches.KEY_4)
	List<NavigationDto> findListByParentIdForTree(final String siteCode, final String typeCode, final String parentId, final int level);

	/**
	 * 查询:导航
	 *
	 * @param siteCode
	 *          站代码
	 * @param typeCode
	 *          类别代码
	 * @param parentId
	 *          父级标识
	 * @return 导航对象集合
	 */
	@Cacheable(value = NavigationService.BEAN_ID, key = Caches.KEY_3)
	List<NavigationDto> findListByParentId(final String siteCode, final String typeCode, final String parentId);

	/**
	 * 查询:导航
	 *
	 * @param siteCode
	 *          站代码
	 * @param typeCode
	 *          类别代码
	 * @param parentCode
	 *          父级代码
	 * @return 导航对象集合
	 */
	@Cacheable(value = NavigationService.BEAN_ID, key = Caches.KEY_3)
	List<NavigationDto> findListByParentCode(final String siteCode, final String typeCode, final String parentCode);

	/**
	 * 查询:导航
	 *
	 * @param siteCode
	 *          站代码
	 * @param typeCode
	 *          类别代码
	 * @param parentCode
	 *          父级代码
	 * @param level
	 *          层级
	 * @return 导航对象集合
	 */
	@Cacheable(value = NavigationService.BEAN_ID, key = Caches.KEY_4)
	List<NavigationDto> findListByParentCodeForTree(final String siteCode, final String typeCode, final String parentCode, final int level);

	/**
	 * 初始化数据字典
	 *
	 * @param initNavigationList
	 *          初始化数据字典对象集合
	 * @return
	 */
	@Transactional
	@CacheEvict(value = NavigationService.BEAN_ID, allEntries = true)
	void init(final List<NavigationDto> initNavigationList);

	/**
	 * 插入
	 *
	 * @param insertNavigation
	 *          导航对象
	 *
	 * @return 影响行数
	 */
	@Deprecated
	@Transactional
	@CacheEvict(value = NavigationService.BEAN_ID, allEntries = true)
	int insertByCode(final NavigationDto insertNavigation);

	/**
	 * 删除
	 *
	 * @param deleteNavigation
	 *          导航对象
	 *
	 * @return 影响行数
	 */
	@Deprecated
	@Transactional
	@CacheEvict(value = NavigationService.BEAN_ID, allEntries = true)
	int deleteByIds(final NavigationDto deleteNavigation);

	/**
	 * 更新
	 *
	 * @param updateNavigation
	 *          导航对象
	 *
	 * @return 影响行数
	 */
	@Deprecated
	@Transactional
	@CacheEvict(value = NavigationService.BEAN_ID, allEntries = true)
	int updateByCode(final NavigationDto updateNavigation);

	/**
	 * 查询
	 *
	 * @param readNavigation
	 *          导航对象
	 * @return 返回数据
	 */
	@Deprecated
	@Cacheable(value = SiteUrlService.BEAN_ID, key = Caches.KEY_1)
	Integer readByCodeNqIdForCount(final NavigationDto readNavigation);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param findNavigation
	 *          导航对象
	 * @return 返回对象
	 */
	@Deprecated
	@Cacheable(value = SiteUrlService.BEAN_ID, key = Caches.KEY_2)
	<P> P findById(final Class<P> mappedClass, final NavigationDto findNavigation);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param findNavigation
	 *          导航对象
	 *
	 * @return 返回对象
	 */
	@Deprecated
	@Cacheable(value = SiteUrlService.BEAN_ID, key = Caches.KEY_2)
	<P> P findByCodeOrId(final Class<P> mappedClass, final NavigationDto findNavigation);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param findListNavigation
	 *          导航对象
	 *
	 * @return 导航对象集合
	 */
	@Cacheable(value = SiteUrlService.BEAN_ID, key = Caches.KEY_2)
	<P> List<P> findListByLikeCode(final Class<P> mappedClass, final NavigationDto findListNavigation);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @return 导航对象集合
	 */
	@Cacheable(value = NavigationService.BEAN_ID, key = Caches.KEY_1)
	<P> List<P> findList(final Class<P> mappedClass);

	/**
	 * 分页
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param paginationNavigation
	 *          导航对象
	 *
	 * @return 导航分页对象
	 */
	@Cacheable(value = SiteUrlService.BEAN_ID, key = Caches.KEY_2)
	<P> PaginationDto<P> paginationByLikeCode(final Class<P> mappedClass, final NavigationDto paginationNavigation);
}